function updateLLR_pscd(i,j)
% PCparams structure is implicit parameter
%
% Non-Recursive implementation of the SCD update Likelihoods routine
 
global PCparams;
n = PCparams.n;
N = PCparams.N;
PI = PCparams.PI;
if(i>=N || j>=n)
    %fprintf('into %d,%d\n',i,j);
    return 
end
%s = 2^(n-j);
s = 2^(1+PI(n-j));
l = mod(i,s);
s_2 = fix(s/2);
%fprintf('into %d,%d,%d\n',i,j,s_2);



if(l<s_2)
    if(PCparams.LLRpscd(i+1,j+2)==0)
        updateLLR_pscd(i,j+1);
    end
    if(i+s_2+1<=N)
        if(PCparams.LLRpscd(i+s_2+1,j+2)==0)
            updateLLR_pscd(i+s_2,j+1);
        end
        PCparams.LLRpscd(i+1,j+1) = upperconv(PCparams.LLRpscd(i+1,j+2),PCparams.LLRpscd(i+s_2+1,j+2));
    end
else
    PCparams.LLRpscd(i+1,j+1) = lowerconv(...
                           PCparams.BITSpscd(i-s_2+1,j+1), ...
                           PCparams.LLRpscd(i+1,j+2), ...
                           PCparams.LLRpscd(i+1-s_2,j+2) ...
                           );
                       
%     if(PCparams.BITSpscd(i+1,j+1)==0)
%         PCparams.LLR(i+1,j+1) = PCparams.LLR(i+1,j+2)*PCparams.LLR(i+1-s_2,j+1);
%     else
%         PCparams.LLR(i+1,j+1) = PCparams.LLR(i+1,j+2)/PCparams.LLR(i+1-s_2,j+2);
%     end
end
end
